

package com.pe.adexus.portal3g.componente;

/*
 * @Autor : Javier Huarniz R.
 * @Date : 04/02/2009
 * @Definition : Clase de identificacion de navegador usado por el cliente.
 * */
public class Browser {

	
	public static final String[] MOBILE_LIST ={
		// Manufacturers
		"mobileexplorer",
		"palmsource",
		"palmscape",
		"motorola",
		"nokia",
		"blackberry",
		"sony",
		"ipod",
		"vario",
		// Browsers
		"operamini",
		"opera mini",
		"opera mobi",
		"operamobi",
		"mobilexplorer",
		"obigo",
		"netfront",
		"openwave",
		"vodafone",
		"novarra",
		"iemobile",
		// Operating Systems
		"symbian",
		"SymbianOS", 
		"elaine",
		"palm",
		"series60",
		"windows ce",
		//Others
		"mobile",
		"wireless",
		"j2me",
		"midp",
		"cldc",
		"up.link",
		"up.browser",
		"smartphone",
		"cellphone"
		};
	
	
	//Lista de posibles navegadores moviles con problemas en el iframe
	public static final String[] MOBILE_LIST_IFRAME_ERROR ={		
		"nokia"
		};
	
	public static boolean isMobile(String userAgent){
		userAgent = userAgent.toLowerCase();
		//System.out.println("userAgent:"+userAgent);
		for( int i = 0; i<MOBILE_LIST.length; i++ ){
			if( userAgent.contains(MOBILE_LIST[i]) )
				return true;
		}
		return false;		
		
	}
	
	/*
	 * Esta funcion va a redirecionar a los navegardores con problemas
	 * con el iframe y el autoscroll
	 * 
	 * */
	public static boolean hasIframe_error(String userAgent){
		userAgent = userAgent.toLowerCase();
		//System.out.println("userAgent:"+userAgent);
		for( int i = 0; i<MOBILE_LIST_IFRAME_ERROR.length; i++ ){
			if( userAgent.contains(MOBILE_LIST_IFRAME_ERROR[i]) )
				return true;
		}
		return false;		
		
	}
	
}
